package name.matthewgreet.example1.action; import javax.servlet.http.HttpSession; import org.apache.struts2.convention.annotation.Action; import org.apache.struts2.convention.annotation.InterceptorRef; import org.apache.struts2.convention.annotation.Result; import org.apache.struts2.convention.annotation.Results; import com.opensymphony.xwork2.ActionSupport; import com.opensymphony.xwork2.ModelDriven; import name.matthewgreet.example1.common.AbstractActionSupport; import name.matthewgreet.example1.form.CountryForm; import name.matthewgreet.example1.vo.CountryVO; /** * Saves country data. */ @InterceptorRef("FormDrivenStack") @Results({ @Result(name=ActionSupport.INPUT, type="redirectAction", params = {"namespace", "/", "actionName", "ViewCountry"}), @Result(name=ActionSupport.SUCCESS, type="redirectAction", params = {"namespace", "/", "actionName", "ViewCountry"}) }) public class SaveCountryAction extends AbstractActionSupport implements ModelDriven<CountryForm> { private static final long serialVersionUID = -700627736127116372L; private CountryForm form; public SaveCountryAction() { super(); form = new CountryForm(); } @Action("/SaveCountry") @Override public String execute() throws Exception { CountryVO foundCountry; HttpSession session; session = getBrowserTabSession(); foundCountry = ViewCountryListAction.retrieveSearchResults(session).getSelected(); if (foundCountry != null) { foundCountry.setCode(form.getCode()); foundCountry.setName(form.getName()); foundCountry.setNotes(form.getNotes()); } return SUCCESS; } @Override public CountryForm getModel() { return form; } }